package client.UI_stuff;

import com.google.gwt.user.client.ui.*;

import java.util.*;

import client.*;

/**
 * ContactListWidget
 *
 * @author Masud Idris
 * @version 1.0
 * @since Dec 19, 2007, 12:13:32 PM
 */
public class ContactListWidget extends Composite {
  private VerticalPanel basePanel;
  private FlexTable displayTable;


  /**
   * Constructor
   * @param contactList List of contacts to be displayed
   */
  public ContactListWidget(ArrayList contactList) {
    basePanel = new VerticalPanel();
    displayTable = new FlexTable();

    initWidget(basePanel);

    setStyleName("contact-list-widget");
    basePanel.add(displayTable);

    displayContactList(contactList);
  }


  /**
   * Displays a list of contacts
   * @param contactList list of contacts to display
   */
  public void displayContactList(ArrayList contactList) {
    displayTable.setWidget(0, 0, new HTML("<strong>List of Contacts</strong>"));
    for(int i=0; i<contactList.size(); i++) {
      displayTable.setWidget(i+1, 0, new ContactWidget((Contact) contactList.get(i)));
    }
  }

}//end class ContactListWidget
